package cn.com.huzo.service.manufacture.impl;

import cn.com.huzo.model.entities.manufacture.CmtSettlementSlipLinesEntity;
import huzofw.service.impl.GenericManagerImpl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.com.huzo.repository.manufacture.CmtSettlementSlipLinesRepository;
import cn.com.huzo.service.manufacture.CmtSettlementSlipLinesManager;

/**
 * 加工费计算明细管理服务对象类实现。
 *
 * @author 吴旭
 */
@Service("CmtSettlementSlipLinesManager")
public class CmtSettlementSlipLinesManagerImpl extends GenericManagerImpl<CmtSettlementSlipLinesEntity, String>
        implements CmtSettlementSlipLinesManager {

    @Resource(name = "CmtSettlementSlipLinesRepository")
    private CmtSettlementSlipLinesRepository _dao_lines;

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Transactional
    @Override
    public List<CmtSettlementSlipLinesEntity> fetchByHeaderId(Long headerId) throws Exception {
        return _dao_lines.fetchByHeaderId(headerId);
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Transactional
    @Override
    public Map<String, Object> insertLinesByHandCut(Map<String, Object> criterion) throws Exception {
        Map<String, Object> _result = new HashMap();
        _result.put("RowsAffected", _dao_lines.insertLinesByHandCut(criterion));
        _result.put("LinesList", _dao_lines.fetchByHeaderId(MapUtils.getLong(criterion, "HeaderId")));
        return _result;
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Transactional
    @Override
    public Map<String, Object> batchUpdate(List<CmtSettlementSlipLinesEntity> itemList) throws Exception {
        _dao_lines.batchUpdate(itemList);
        return null;
    }

    /**
     * {@inheritDoc}
     *
     * @throws java.lang.Exception
     */
    @Transactional
    @Override
    public Map<String, Object> delete(Map<String, Object> criterion) throws Exception {
        //_dao_lines.delete(instance.getLinesId());
        //return _dao_lines.fetchByHeaderKey(instance.getHeaderId());
        return null;
    }
}
